(function(){"use strict";BX.namespace("BX.TileGrid");BX.TileGrid.DragDrop=function(t){this.gridTile=t;this.draggableContainer=null;this.droppableItem=null;this.draggableItems=[]};BX.TileGrid.DragDrop.prototype={registerItem:function(t){t.onbxdragstart=BX.proxy(this.onDragStart,this);t.onbxdrag=BX.proxy(this.onDrag,this);t.onbxdragstop=BX.proxy(this.onDragStop,this);t.onbxdraghover=BX.proxy(this.onDragOver,this);t.onbxdraghout=BX.proxy(this.onDragOut,this);jsDD.registerObject(t)},registerDrop:function(t){jsDD.registerDest(t,10)},onDragStart:function(){this.setDraggableItems();this.setDraggableContainer();var t=BX.proxy_context;var e=this.gridTile.getItem(t.dataset.id);if(!e.selected){this.gridTile.resetSelectAllItems();this.draggableItems=[];this.draggableItems.push(e)}var i;var a=this.draggableItems[0].layout.container.offsetWidth;for(var r=0;r<this.draggableItems.length;r++){i=this.draggableItems[r].layout.container.cloneNode(true);i.style.width=a+"px";this.draggableContainer.appendChild(i);this.toggleActiveClass(this.draggableItems[r].layout.container)}BX.onCustomEvent(this.gridTile,"TileGrid.Grid:onItemDragStart",[this]);document.body.appendChild(this.draggableContainer)},onDrag:function(t,e){this.draggableContainer.style.left=t+"px";this.draggableContainer.style.top=e+"px"},onDragOver:function(t){this.handlerDroppableClass();var e=t.dataset.id;this.droppableItem=this.gridTile.getItem(e);this.handlerDroppableClass();BX.onCustomEvent(this.gridTile,"TileGrid.Grid:onItemDragOver",[this])},onDragOut:function(t){this.handlerDroppableClass();this.droppableItem=null;BX.onCustomEvent(this.gridTile,"TileGrid.Grid:onItemDragOut",[this])},handlerDroppableClass:function(){if(!this.droppableItem)return;BX.toggleClass(this.droppableItem.layout.container,"ui-grid-tile-item-droppable")},onDragStop:function(){this.gridTile.resetSelectAllItems();this.moveDraggableItems();this.handlerDroppableClass();for(var t=0;t<this.draggableItems.length;t++){this.toggleActiveClass(this.draggableItems[t].layout.container)}this.draggableContainer.parentNode.removeChild(this.draggableContainer);this.draggableItems=[];this.droppableItem=null;this.draggableContainer=null;BX.onCustomEvent(this.gridTile,"TileGrid.Grid:onItemDragStop",[this])},moveDraggableItems:function(){for(var t=0;t<this.draggableItems.length;t++){if(this.draggableItems[t]===this.droppableItem)return}if(!this.droppableItem)return;if(this.droppableItem.isDroppable){this.droppableItem.animateNode();for(var e=0;e<this.draggableItems.length;e++){this.gridTile.moveItem(this.draggableItems[e],this.droppableItem)}}},setDraggableItems:function(){for(var t=0;t<this.gridTile.items.length;t++){this.gridTile.items[t].selected?this.draggableItems.push(this.gridTile.items[t]):null}},setDraggableContainer:function(){this.draggableContainer=BX.create("div",{attrs:{className:this.draggableItems.length<=1?"ui-grid-tile-item-draggable-single":"ui-grid-tile-item-draggable"},style:{width:this.draggableItems.length>1?this.draggableItems[0].layout.container.offsetWidth+"px":null,height:this.draggableItems.length>1?this.draggableItems[0].layout.container.offsetHeight+"px":null}})},toggleActiveClass:function(t){t.classList.contains("ui-grid-tile-item-active")?t.classList.remove("ui-grid-tile-item-active"):t.classList.add("ui-grid-tile-item-active")}}})();